﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Finance.IBll;
using Finance.IDal;
using Finance.Poco;
using Finance.Entity;
using Finance.Dal;

namespace Finance.Bll
{
    public class UserBll:IUserBll
    {
        IUserDal userDal = new UserDal();
        public bool ChangePassword(string username, string oldPasswordEnc, string newPasswordEnc)
        {
           return  userDal.ChangePassword(username, oldPasswordEnc, newPasswordEnc);
        }

        //public bool CreateUser(string username, string passwordEnc, string email, string passwordQuestion, string passwordAnswer, bool isApproved)
        //{
        //  return   userDal.CreateUser(username, passwordEnc, email, passwordQuestion, passwordAnswer, isApproved);
        //}

        public bool CreateUser(string username, string passwordEnc, string email, string passwordQuestion, string passwordAnswer, bool isApproved, object providerUserKey,int orgId)
        {
           return  userDal.CreateUser(username, passwordEnc, email, passwordQuestion, passwordAnswer, isApproved,providerUserKey,orgId);
        }

        public Entity.UserEntity GetUser(object providerUserKey, bool userIsOnline)
        {
           return  userDal.GetUser(providerUserKey, userIsOnline);
        }




        public UserEntity GetUser(string userName, bool userIsOnline)
        {
            return userDal.GetUser(userName, userIsOnline);
        }

        public bool ValidateUser(string username, string passwordEnc)
        {
            return userDal.ValidateUser(username, passwordEnc);
        }

        public string GetUserNameByEmail(string email)
        {
            return userDal.GetUserNameByEmail(email);
        }

        public bool ResetPassword(string username, string answer, string newPasswordEnc)
        {
            return userDal.ResetPassword(username, answer,newPasswordEnc);
        }

        public bool UnlockUser(string userName)
        {
            return userDal.UnlockUser(userName);
        }

        public void UpdateUser(UserEntity userEntity)
        {
            userDal.UpdateUser(userEntity);
        }

        public bool DeleteUser(string username, bool deleteAllRelatedData)
        {
            return userDal.DeleteUser(username, deleteAllRelatedData);
        }


        public IEnumerable<ViewUserEntity> List(string userName, int pageIndex, int pageSize, out int total)
        {
            return userDal.List(userName, pageIndex, pageSize, out total);
        }

        public bool ResetPassword(string userName, string passwordEnc)
        {
            return userDal.ResetPassword(userName, passwordEnc);
        }

        public bool UpdateUser(int id, string realName, string email, int orgId)
        {
            return userDal.UpdateUser(id, realName, email,orgId);
        }


        public bool DeleteUser(int id)
        {
            return userDal.DeleteUser(id);
        }


        public IEnumerable<ViewUserEntity> List(int orgId)
        {
            return userDal.List(orgId);
        }
    }
}
